Skip to content

Conversation

@slaclau
Copy link
Collaborator

@slaclau slaclau commented Mar 27, 2024

Addresses #112

  • Add customreboot functionality
  • Add preferences for customreboot

static async SetBootOption(id) {
try {
let [status, stdout, stderr] = await ExecCommand(
['/usr/bin/pkexec', '/usr/sbin/grub-reboot', id],
Copy link
Contributor

@City-busz City-busz Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grub-reboot? It doesn't seem to be correct here for systemd boot. bootctl set-oneshot should be here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also an issue reflected in the 'upstream', thanks for reminding me. I don't use systemd-boot so haven't tested this yet.

'pkexec',
'sh',
'-c',
`/usr/bin/cp ${Extension.lookupByUUID('hibernate-status@dromi').path}/customreboot/42_custom_reboot /etc/grub.d/42_custom_reboot && /usr/bin/chmod 755 /etc/grub.d/42_custom_reboot && /usr/sbin/update-grub`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update-grub command has been replaced by grub-mkconfig: https://git.savannah.gnu.org/cgit/grub.git/tree/NEWS#n537

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this, thanks.

@City-busz
Copy link
Contributor

I don't think that quick reboot functionality is good in the current form. Regenerating the grub config needs extra caution, because it can break boot, especially with custom configs. And the timeout will remain disabled if e.g. the user logs in into a session other than GNOME after reboot, or not authenticated to run the command to reconfigure grub.

I think it would better to drop this functionality.

@slaclau
Copy link
Collaborator Author

slaclau commented Mar 29, 2024

The code in its current from mostly comes from https://extensions.gnome.org/extension/5542/custom-reboot/, I do agree about the issue with disabling the timeout

if (bootOps !== undefined) {
this._itemsSection = new PopupMenu.PopupMenuSection();

for (let [title, id] of bootOps) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title and id fields are swapped here. systemdBoot.js and efibootmgr.js sets the id as first parameter, and title is the second parameter.

@City-busz
Copy link
Contributor

City-busz commented Mar 30, 2024

Generally, I think it would better to implement this functionality based on the D-Bus interface of systemd-logind. You can get the boot loader entries by reading BootLoaderEntries, and there is a SetRebootToBootLoaderEntry() method.

UPDATE:
However, BootLoaderEntries just gives the list of IDs, but not the titles, so the current code that process the output of bootctl list gives better result.

For the reboot, it would better to use the SetRebootToBootLoaderEntry() D-Bus method (or the command systemctl reboot --boot-loader-entry=ID), because it does not require to be authenticated as root, since reboot is allowed for all users by default. But it needs some refactoring, a custom reboot dialog is needed for this feature.

@slaclau slaclau marked this pull request as draft February 24, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants